﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NamesPredicatLINQ
{
    class NamesPredicate
    {
        static void Main(string[] args)
        {
            var names = new[] {
                                 new { First = "Ivan", Second = "Petrov"},
                                 new { First = "Georgi", Second = "Geshev"},
                                 new { First = "Ivan", Second = "Stoianov"},
                                 new { First = "Tosho", Second = "Nqkoisi"},
                                 new { First = "Pesho", Second = "Nikolov"},
                              };

          var firstNames =
          from name in names
          where name.First.CompareTo(name.Second) < 0
          select name;

          foreach (var name in firstNames)
          {
              Console.WriteLine(name);
          }

          var students = new[] {
                                 new { First = "Ivan", Second = "Petrov", Age = 25},
                                 new { First = "Georgi", Second = "Geshev", Age = 22},
                                 new { First = "Ivan", Second = "Stoianov", Age = 21},
                                 new { First = "Tosho", Second = "Nqkoisi", Age = 55},
                                 new { First = "Pesho", Second = "Nikolov", Age = 44},
                              };
           
          var oldEnoughStudents =
              from student in students
              where student.Age >= 18 && student.Age <= 24
              select student.First;

          foreach (var name in oldEnoughStudents)
          {
              Console.WriteLine(name);
          }
        }
    }
}
